package com.loyi.cloud.hbsystem.datashare.autoconfig;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.encoding.FeignAcceptGzipEncodingInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.loyi.cloud.hbmis.api.IQueryService;
import com.loyi.cloud.hbmis.api.feign.impl.IFeignQueryService;
import com.loyi.cloud.hbsystem.datashare.commons.autoconfig.DataShareConfigProperties;
import com.loyi.cloud.hbsystem.datashare.service.GISAnalyserExportTask;
import com.loyi.cloud.hbsystem.datashare.web.GisDataExportService;

import feign.Feign;

@Configuration
@EnableFeignClients(basePackageClasses = { IFeignQueryService.class })
@ComponentScan(basePackageClasses = { GisDataExportService.class })
@EnableConfigurationProperties(value = { DataShareConfigProperties.class })
public class DataShareGISAutoConfiguration {

	@Autowired
	private DataShareConfigProperties properties;

	@Autowired
	private IFeignQueryService queryService;

	@Bean
	public GISAnalyserExportTask dayAnalyserExport() {
		GISAnalyserExportTask task = new GISAnalyserExportTask();
		task.setVfspath(properties.getLocalPath());
		task.setTitle("河北省环境空气质量污染物浓度分布图");
		task.setTimepattern("yyyy-MM-dd HH:mm:ss");
		task.setType(1);
		task.setScope(24);
		task.setQueryService(this.queryService);
		List<Map<String, Object>> polls = new ArrayList<Map<String, Object>>();

		Map<String, Object> p;

		p = new HashMap<String, Object>();
		p.put("pollcode", "448A");
		p.put("othercode", "448A");
		p.put("name", "pm25");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4486");
		p.put("othercode", "4486");
		p.put("name", "pm10");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4402");
		p.put("othercode", "4402");
		p.put("name", "SO2");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4404");
		p.put("othercode", "4404");
		p.put("name", "CO");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4467");
		p.put("othercode", "4467");
		p.put("name", "NO2");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4D71");
		p.put("othercode", "4D71");
		p.put("name", "O3");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "aqi");
		p.put("othercode", "aqi");
		p.put("name", "aqi");
		p.put("unit", "1");
		polls.add(p);
		task.setPolls(polls);
		return task;
	}

	@Bean
	public GISAnalyserExportTask hourAnalyserExport() {
		GISAnalyserExportTask task = new GISAnalyserExportTask();
		task.setVfspath(properties.getLocalPath());
		task.setTitle("河北省环境空气质量污染物浓度分布图");
		task.setTimepattern("yyyy-MM-dd HH:mm:ss");
		task.setType(0);
		task.setScope(1);
		task.setQueryService(this.queryService);
		List<Map<String, Object>> polls = new ArrayList<Map<String, Object>>();

		Map<String, Object> p;

		p = new HashMap<String, Object>();
		p.put("pollcode", "448A");
		p.put("othercode", "448A");
		p.put("name", "pm25");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4486");
		p.put("othercode", "4486");
		p.put("name", "pm10");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4402");
		p.put("othercode", "4402");
		p.put("name", "SO2");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4404");
		p.put("othercode", "4404");
		p.put("name", "CO");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4467");
		p.put("othercode", "4467");
		p.put("name", "NO2");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "4D71");
		p.put("othercode", "4D71");
		p.put("name", "O3");
		p.put("unit", "1000");
		polls.add(p);

		p = new HashMap<String, Object>();
		p.put("pollcode", "aqi");
		p.put("othercode", "aqi");
		p.put("name", "aqi");
		p.put("unit", "1");
		polls.add(p);
		task.setPolls(polls);
		return task;
	}

}
